from django.db import models


# Create your models here.


class account(models.Model):
    id = models.CharField(max_length=255, primary_key=True)
    password = models.CharField(max_length=255)
    role = models.IntegerField(default=0)


class student(models.Model):
    stu_id = models.ForeignKey(account, on_delete=models.CASCADE)
    name = models.CharField(max_length=255)
    balance = models.FloatField(default=0)


class teacher(models.Model):
    tea_id = models.ForeignKey(account, on_delete=models.CASCADE)
    name = models.CharField(max_length=255)
    card_account = models.CharField(max_length=255)


class reservation(models.Model):
    reservation_id = models.IntegerField(range(1, 99999999), primary_key=True)
    create_time = models.DateTimeField()
    student_id = models.ForeignKey(student, on_delete=models.CASCADE)
    teacher_id = models.ForeignKey(teacher, on_delete=models.CASCADE)


class coach(models.Model):
    reservation_id = models.IntegerField(range(1, 99999999), primary_key=True)
    coach_status = models.IntegerField(range(1, 99))
    score = models.IntegerField(range(1, 99))
    trade_status = models.IntegerField(range(1, 99))


class collectbox(models.Model):
    id = models.ForeignKey(account, on_delete=models.CASCADE)
    collectbox_id = models.IntegerField(range(1, 99999999), primary_key=True)
    name = models.CharField(max_length=255)
    category = models.CharField(max_length=255)
    content = models.CharField(max_length=255)


class collectbox_like(models.Model):
    id = models.CharField(max_length=255, primary_key=True)
    collectbox_id = models.ForeignKey(collectbox, on_delete=models.CASCADE)
    create_time = models.DateTimeField()


class chat(models.Model):
    send_id = models.CharField(max_length=255)
    receive = models.CharField(max_length=255)
    create_time = models.DateTimeField(primary_key=True)
    content = models.CharField(max_length=255)

    class Meta:
        unique_together = ("send_id", "receive")


class blog_like(models.Model):
    u_id = models.CharField(max_length=255)
    blog_id = models.IntegerField(range(1, 99999999))
    create_time = models.DateTimeField()

    class Meta:
        unique_together = ("u_id", "blog_id")


class blog(models.Model):
    blog_id = models.IntegerField(range(1, 99999999), primary_key=True)
    id = models.ForeignKey(account, on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    content = models.CharField(max_length=255)
    create_time = models.DateTimeField()
    visable = models.IntegerField(range(1, 99))


class blog_reward(models.Model):
    id = models.CharField(max_length=255, primary_key=True)
    blog_id = models.ForeignKey(blog, on_delete=models.CASCADE)
    reward_amount = models.FloatField(default=0)
    create_time = models.DateTimeField()


class blog_comment(models.Model):
    u_id = models.CharField(max_length=255)
    blog_id = models.IntegerField(range(1, 99999999))
    content = models.CharField(max_length=255)
    create_time = models.DateTimeField()

    class Meta:
        unique_together = ("u_id", "blog_id")
